home *** CD-ROM | disk | FTP | other *** search
- #include "windows.h"
- #include "mda_spy.h"
- #include "time.h"
- #include "io.h"
- #include "stdio.h"
-
- char szAppName[10];
- char szMessage[15];
- int MessageLength;
-
- static HANDLE hInst;
- extern void spycls(void);
- extern void spystr(char *,char,char);
- extern void spytoa(int,char,char);
- extern void spyarr(char ,int,char,char);
-
- long FAR PASCAL Mda_SpyWndProc(HWND, unsigned, WORD, LONG);
-
-
- void Mda_SpyPaint( hDC )
- HDC hDC;
- {
- TextOut( hDC,
- (short)10,
- (short)10,
- (LPSTR)szMessage,
- (short)MessageLength );
- }
-
-
- BOOL Mda_SpyInit( hInstance )
- HANDLE hInstance;
- {
- PWNDCLASS pMda_SpyClass;
-
- LoadString( hInstance, IDSNAME, (LPSTR)szAppName, 10 );
- MessageLength = LoadString( hInstance, IDSTITLE, (LPSTR)szMessage, 15 );
-
- pMda_SpyClass = (PWNDCLASS)LocalAlloc( LPTR, sizeof(WNDCLASS) );
-
- pMda_SpyClass->hCursor = LoadCursor( NULL, IDC_ARROW );
- pMda_SpyClass->hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(SPYICON) );
- pMda_SpyClass->lpszMenuName = (LPSTR)NULL;
- pMda_SpyClass->lpszClassName = (LPSTR)szAppName;
- pMda_SpyClass->hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
- pMda_SpyClass->hInstance = hInstance;
- pMda_SpyClass->style = CS_HREDRAW | CS_VREDRAW;
- pMda_SpyClass->lpfnWndProc = Mda_SpyWndProc;
-
- if (!RegisterClass( (LPWNDCLASS)pMda_SpyClass ) )
- return FALSE;
-
- LocalFree( (HANDLE)pMda_SpyClass );
- return TRUE; /* Initialization succeeded */
- }
-
-
- int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
- HANDLE hInstance, hPrevInstance;
- LPSTR lpszCmdLine;
- int cmdShow;
- {
- MSG msg;
- HWND hWnd;
- HMENU hMenu;
-
- if (!hPrevInstance) {
- if (!Mda_SpyInit( hInstance ))
- return FALSE;
- }
- else {
- PostQuitMessage(0); }
-
- hWnd = CreateWindow((LPSTR)szAppName,
- (LPSTR)szMessage,
- WS_OVERLAPPEDWINDOW,
- 0, /* x - ignored for tiled windows */
- 0, /* y - ignored for tiled windows */
- 100, /* cx - ignored for tiled windows */
- 100, /* cy - ignored for tiled windows */
- (HWND)NULL, /* no parent */
- (HMENU)NULL, /* use class menu */
- (HANDLE)hInstance, /* handle to window instance */
- (LPSTR)NULL /* no params to pass on */
- );
-
- hInst = hInstance;
-
-
- hMenu = GetSystemMenu(hWnd, FALSE);
- ChangeMenu(hMenu, 0, NULL, 999, MF_APPEND | MF_SEPARATOR);
- ChangeMenu(hMenu, 0, (LPSTR)"MDA_SPY", IDSABOUT, MF_APPEND | MF_STRING);
-
- ShowWindow( hWnd, cmdShow );
- UpdateWindow( hWnd );
-
- while (GetMessage((LPMSG)&msg, NULL, 0, 0)) {
- TranslateMessage((LPMSG)&msg);
- DispatchMessage((LPMSG)&msg);
- }
-
- return (int)msg.wParam;
- }
-
-
- long FAR PASCAL Mda_SpyWndProc( hWnd, message, wParam, lParam )
- HWND hWnd;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- PAINTSTRUCT ps;
- HMENU hMenu;
- switch (message)
- {
- case WM_SYSCOMMAND:
- switch (wParam)
- {
- case IDSABOUT:
- spycls();
- spystr("Hello says the echo",10,2);
- spytoa(20,11,3);
- break;
-
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
- }
- break;
-
- case WM_DESTROY:
- PostQuitMessage( 0 );
- break;
-
- case WM_PAINT:
- BeginPaint( hWnd, (LPPAINTSTRUCT)&ps );
- Mda_SpyPaint( ps.hdc );
- EndPaint( hWnd, (LPPAINTSTRUCT)&ps );
- break;
-
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
- break;
- }
- return(0L);
- }